package com.xtm.exercise.utils;

import org.springframework.context.ApplicationContext;

public class GetSpringBeanUtil {
	private static class Singleton{
		private static ApplicationContext context;
		public static void setApplicationContext(ApplicationContext applicationContext){
			context = applicationContext;
		}
	}

	private GetSpringBeanUtil(){}

	public static void setApplicationContext(ApplicationContext applicationContext){
		Singleton.setApplicationContext(applicationContext);
	}

	public static Object getBean(String beanName){
		return Singleton.context.getBean(beanName);
	}

	public static<T> T getBean(Class<T> classType){
		return Singleton.context.getBean(classType);
	}
}